# Contributor: John Gebbie <me@johngebbie.com>
# Maintainer: John Gebbie <me@johngebbie.com>
pkgname=openfst
pkgver=1.8.2
pkgrel=5
pkgdesc="Finite-state transducers library"
url="https://www.openfst.org"
# doesn't build on other arches
arch="x86_64 aarch64 armv7"
license="Apache-2.0"
subpackages="
	$pkgname-dev
	libfst
	libfstcompact
	libfstconst
	libfstfar
	libfstlookahead
	libfstngram
	"
source="https://www.openfst.org/twiki/pub/FST/FstDownload/openfst-$pkgver.tar.gz
	fix-check.patch"

build() {
	CFLAGS="$CFLAGS -O2" \
	CXXFLAGS="$CXXFLAGS -O2" \
	./configure \
		--build="$CBUILD" \
		--host="$CHOST" \
		--prefix=/usr \
		--disable-bin \
		--disable-dependency-tracking \
		--disable-static \
		--enable-compact-fsts \
		--enable-compress \
		--enable-const-fsts \
		--enable-far \
		--enable-linear-fsts \
		--enable-lookahead-fsts \
		--enable-mpdt \
		--enable-ngram-fsts \
		--enable-pdt \
		--enable-shared \
		--with-pic

	make
}

package() {
	make DESTDIR="$pkgdir" install
}

check() {
	make check
}

libfst() {
	amove usr/lib/libfst.so.*
}

libfstcompact() {
	depends="$pkgname=$pkgver-r$pkgrel"
	amove usr/lib/libfstcompact.so.*
}

libfstconst() {
	depends="$pkgname=$pkgver-r$pkgrel"
	amove usr/lib/libfstconst.so.*
}

libfstfar() {
	depends="$pkgname=$pkgver-r$pkgrel"
	amove usr/lib/libfstfar.so.*
}

libfstlookahead() {
	depends="$pkgname=$pkgver-r$pkgrel"
	amove usr/lib/libfstlookahead.so.*
}

libfstngram() {
	depends="$pkgname=$pkgver-r$pkgrel"
	amove usr/lib/libfstngram.so.*
}

sha512sums="
ca7f9f19e24141e1f1d0bbabf43795e6e278bce3887c14261d9ce204a0e01b1588eaf982755a9105247510a19f67da2f566e9b14b1d869497148f95b55606d5c  openfst-1.8.2.tar.gz
8826567c4a2627e7115ca2269ddaaca5bab4430a8cb3b163106e524023c55983ba1da490ccba0f1379266f42b87dfcdeb0cbb627cf5183e07a7e5fe84d08ed68  fix-check.patch
"
